Page({
  data: {
      currentFilter: 'all',
      orderList: [
          {
              id: 1,
              orderNo: 'DD202412340001',
              status: 'pending',
              statusText: '待付款',
              productImage: '/images/nav/iphon.jpg',
              productName: 'Apple iPhone 15 Pro',
              specification: '深空黑色 256GB',
              price: '7999.00',
              quantity: 1,
              totalAmount: '7999.00'
          },
          {
              id: 2,
              orderNo: 'DD202412340002',
              status: 'shipped',
              statusText: '待发货',
              productImage: '/images/nav/huawei.jpg',
              productName: '华为MateBook X Pro',
              specification: 'i7 16GB 1TB 灰色',
              price: '8999.00',
              quantity: 1,
              totalAmount: '8999.00'
          }
      ]
  },

  onLoad: function(options) {
      console.log('我的订单页面加载');
  },

  switchFilter: function(e) {
      const filter = e.currentTarget.dataset.filter;
      this.setData({
          currentFilter: filter
      });
  },

  cancelOrder: function(e) {
      const orderId = e.currentTarget.dataset.orderid;
      wx.showModal({
          title: '确认取消',
          content: '确定要取消这个订单吗？',
          success: (res) => {
              if (res.confirm) {
                  wx.showToast({
                      title: '订单已取消',
                      icon: 'success'
                  });
              }
          }
      });
  },

  payOrder: function(e) {
      wx.showToast({
          title: '支付成功',
          icon: 'success'
      });
  },

  confirmReceipt: function(e) {
      wx.showModal({
          title: '确认收货',
          content: '请确认您已收到商品',
          success: (res) => {
              if (res.confirm) {
                  wx.showToast({
                      title: '收货成功',
                      icon: 'success'
                  });
              }
          }
      });
  },

  goShopping: function() {
      wx.switchTab({
          url: '/pages/index/index'
      });
  }
});